package com.ctg.itrdc.sysmgr.permission.core.utils;

import java.net.URLEncoder;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

public class CookieUtils {

	public static final String CTG_USER = "ctgUser";
	public static final String DOMAIN = "";
	public static final String PATH = "/";

	public static void setCookie(HttpServletResponse response, String key, String value) {
		Cookie cookie = new Cookie(key, URLEncoder.encode(value));
		cookie.setPath(PATH);
		response.addCookie(cookie);
	}

	public static void cleanCookie(HttpServletResponse response, String key) {
		Cookie cookie = new Cookie(key, null);
		cookie.setMaxAge(0);
		cookie.setPath(PATH);
		response.addCookie(cookie);
	}
}
